<form method="post" action="">
	<label>Username:</label>
	<input name="username"/>
	<br/>
	<label>Password:</label>
	<input name="password" type="password"/>
	<br />
	<input name="url" type="hidden" value="<?php echo base_url();?>"/>
	<input name="url_login" type="hidden" value="<?php echo base_url();?>login"/>
	<a href="http://bhpay.dev/register">Register</a>
	<input type="submit" />
</form>
<?php
$load->model('userModel');
?>

<?php 
if($_SERVER["REQUEST_METHOD"] == "POST")
{
	$u	=	$_POST["username"];
	$p	=	$_POST["password"];
	$url	=	$_POST['url'];
	$url_login	=	$_POST['url_login'];
	
	$user	=	new userModel();
	$_user = $user->check_login($u, $p);
	
	if($_user)
	{
		$session	=	array('username' => $_user['username'], 'fullname' => $_user['fullname'], 'email' => $_user['email']);
		$_SESSION['user']	=	$session;
		
		$session	=	'xxxxx';
		//setcookie('u',$session,time()+(60*60*24*30));
		//setcookie("TestCookie", '12345', time()+3600);
		
		
		//print_r($_COOKIE);die();
		
		echo "<script>location.href='$url';</script>";
	}
	else
	{
		redirect($url_login);
	}
}
//print_r($_SESSION['user']);
?>